package com.walleipt.demo.ioc.importBeanDefinitionRegistrar;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

	public void registerBeanDefinitions(
			AnnotationMetadata importingClassMetadata,
			BeanDefinitionRegistry registry) {
		
		System.err.println( "imprt注解类："+ importingClassMetadata.getClassName() );
		for (String type : importingClassMetadata.getAnnotationTypes()) {
			System.err.println("importingClassMetadata:"+type);
		}
		
		// 将bean注入spring容器中
		RootBeanDefinition rootBeanDefinition = new RootBeanDefinition();
		rootBeanDefinition.setBeanClass(ColorBean.class) ;
		registry.registerBeanDefinition("abc", rootBeanDefinition ) ;
		
	}

}
